package com.wph.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wph.gulimall.product.valid.AddGroup;
import com.wph.gulimall.product.valid.ListValue;
import com.wph.gulimall.product.valid.UpdateGroup;
import com.wph.gulimall.product.valid.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 品牌
 * 
 * @author wupeihong
 * @email wupeihong@gmail.com
 * @date 2020-11-19 18:44:45
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@NotNull(message = "修改必须指定品牌id", groups = {UpdateGroup.class})
	@Null(message = "新增不能指定品牌id", groups = {AddGroup.class})
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名必须提交" ,groups = {AddGroup.class, UpdateGroup.class}) //此注解必须包含一个非空字符串
	private String name;
	/**
	 * 品牌logo地址
	 */
	//这个注解是org.hibernate.validator.constraints.URL;里面的
	//不加分组的注解，默认是不起作用的，  还有没有携带这个数据的时候，就不起作用，什么也不敢，但是携带了，就会收到约束
	@URL(message = "logo必须是一个合法的url地址", groups = {AddGroup.class, UpdateGroup.class})
	@NotBlank(groups = {AddGroup.class})//新增的时候不能为空
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(groups = {AddGroup.class, UpdateStatusGroup.class})
	@ListValue(vals={0,1}, groups = {AddGroup.class, UpdateStatusGroup.class})//多个分组的时候，只要满足一个条件就会生效
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@Pattern(regexp="^[a-zA-Z]$",message = "检索首字母必须是一个字母", groups = {AddGroup.class, UpdateGroup.class})
	@NotEmpty(groups = {AddGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@Min(value = 0, message = "排序必须大于等于0", groups = {AddGroup.class, UpdateGroup.class})
	@NotNull(groups = {AddGroup.class})
	private Integer sort;

}
